/**
* 参数处理
* @param {*} params  参数
*/
export function tansParams(params: any) {
  let result = ''
  for (const propName of Object.keys(params)) {
    const value = params[propName];
    var part = encodeURIComponent(propName) + "=";
    if (value !== null && value !== "" && typeof (value) !== "undefined") {
      if (typeof value === 'object') {
        for (const key of Object.keys(value)) {
          if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') {
            let params = propName + '[' + key + ']';
            var subPart = encodeURIComponent(params) + "=";
            result += subPart + encodeURIComponent(value[key]) + "&";
          }
        }
      } else {
        result += part + encodeURIComponent(value) + "&";
      }
    }
  }
  return result
}

export function randomText(strs: string) {
  let text = strs ?? "qwertyuiopasdfghjklzxcvbnm";
  let letters = text[Math.floor(Math.random() * text.length)]
  return letters
}

// 表单重置
export function resetForm(refName: any) {
  if (this.$refs[refName]) {
    this.$refs[refName].resetFields();
  }
}
